home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 13473 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.2 KB  |  38 lines

  1. Path: columba.udac.uu.se!evolution!thomas
  2. From: Thomas <thomas@evolution.bmc.uu.se>
  3. Newsgroups: comp.lang.c++
  4. Subject: Reverting of big array ?
  5. Date: Tue, 26 Mar 1996 13:34:48 +0100
  6. Organization: Uppsala University
  7. Message-ID: <Pine.SOL.3.91.960326132111.6385A-100000@evolution>
  8. NNTP-Posting-Host: evolution.bmc.uu.se
  9. Mime-Version: 1.0
  10. Content-Type: TEXT/PLAIN; charset=US-ASCII
  11. X-Sender: thomas@evolution
  12.  
  13. I need to revert an array (of chars).
  14. I used the folowing code:( l=length of array)
  15.  
  16.   char *rev=new char[l+1];
  17.   for(i=l-1,j=0;i>=0;i--,j++)  rev[j]=seq[i];    
  18.   rev[j]='\0';    
  19.  
  20. this code works, but is terribly slow, when using an string with 
  21. size ~ 6000.
  22. doing the same with the unix command 'rev' takes 1/2 second.
  23.  
  24. Any ideas  ???
  25.  
  26. -thomas
  27.  
  28. Sicheritz Ponten Thomas E.              UPPSALA UNIVERSITY 
  29. Vangsbyvaegen 128   S-740 20 Vaenge     Biomedical Center
  30. Home: +46 18  364358                    Department of Molecular Biology
  31. BMC:  +46 18  174379                    BOX 590 S-751 24 UPPSALA Sweden
  32. Fax   +46 18  557723                    http://skydancer.bmc.uu.se/~thomas
  33.  
  34.         Chaos always defeats order, 
  35.                 because it is better organized.
  36.                                                (Terry Pratchett)
  37.  
  38.